<template>
<div>
  <button v-if="!setShow" :class="[{succeed : isSucceed, underway : isUnderway ,nostart : isNostart, empty:isEmpty,gray:isGray}, 'button-status']" disabled type="button">{{setStatus}}</button>
  <p v-else>{{setStatus}}</p> 
</div>
</template>

<script>
export default {
  props: {
    label: {
      type: String | Array
    },
    type: {
      type: String
    }
  },
  data() {
    return {
      isSucceed: false,
      isUnderway: false,
      isNostart: false,
      isEmpty: false,
      isGray: false
    };
  },
  methods: {},
  mounted() {},
  computed: {
    setShow: function() {
      return isArray(this.label);
    },
    setStatus: function() {
      this.isSucceed = false;
      this.isUnderway = false;
      this.isNostart = false;
      this.isEmpty = false;
      this.isGray = false;
      var val = "";
      if (isArray(this.label)) {
        if (isNoEmpty(this.label)) {
          for (let i = 0; i < this.label.length; i++) {
            if (i == this.label.length - 1) {
              val += getValueByKey(this.type, this.label[i]);
            } else {
              val += getValueByKey(this.type, this.label[i]) + ",";
            }
          }
        }
      } else {
        if (
          this.label + "" == "qiyong" ||
          this.label + "" == "yibangding" ||
          this.label + "" == "pass"
        ) {
          this.isSucceed = true;
        } else if (
          this.label + "" == "tingyong" ||
          this.label + "" == "refuse"
        ) {
          this.isNostart = true;
        } else if (
          this.label + "" == "weibangding" ||
          this.label + "" == "checking"
        ) {
          this.isUnderway = true;
        } else if (this.label + "" == "daiyong") {
          this.isGray = true;
        }

        val = getValueByKey(this.type, this.label);
      }

      if (val == "" || val == null || val == undefined) {
        this.isEmpty = true;
      }

      return val;
    }
  }
};
</script>

<style scoped>
.button-status {
  width: 60px;
  height: 25px;
  line-height: 5px;
  border-radius: 3px;
}

.succeed {
  border: 1px solid #b7eb8f;
  color: #52c41a;
  background-color: #f6ffed;
}

.underway {
  border: 1px solid #ffbb96;
  color: #fa541c;
  background-color: #fff2e8;
}

.nostart {
  border: 1px solid #f75e65;
  color: #f75e65;
  background-color: #fef0ef;
}

.empty {
  display: none;
}

.gray {
  border: 1px solid rgba(217, 217, 217, 1);
  color: rgba(0, 0, 0, 0.4);
  background-color: rgba(245, 245, 245, 1);
}
</style>